Outdated CHICKEN release

This is a manual page for an old and unsupported version of CHICKEN. If you are still using it, please consider migrating to the latest version. You can find the manual for the latest release here.

  1. Outdated CHICKEN release
  2. Unit srfi-18
    1. thread-signal!
    2. thread-quantum
    3. thread-quantum-set!
    4. thread-suspend!
    5. thread-resume!
    6. thread-wait-for-i/o!
    7. time->milliseconds
    8. milliseconds->time

Unit srfi-18

A simple multithreading package. This threading package follows largely the specification of SRFI-18. For more information see the documentation for SRFI-18.

Notes:

The following procedures are provided, in addition to the procedures defined in SRFI-18:

thread-signal!

[procedure] (thread-signal! THREAD X)

This will cause THREAD to signal the condition X once it is scheduled for execution. After signalling the condition, the thread continues with its normal execution.

thread-quantum

[procedure] (thread-quantum THREAD)

Returns the quantum of THREAD, which is an exact integer specifying the approximate time-slice of the thread in milliseconds.

thread-quantum-set!

[procedure] (thread-quantum-set! THREAD QUANTUM)

Sets the quantum of THREAD to QUANTUM.

thread-suspend!

[procedure] (thread-suspend! THREAD)

Suspends the execution of THREAD until resumed.

thread-resume!

[procedure] (thread-resume! THREAD)

Readies the suspended thread THREAD.

thread-wait-for-i/o!

[procedure] (thread-wait-for-i/o! FD [MODE])

Suspends the current thread until input (MODE is #:input), output (MODE is #:output) or both (MODE is #:all) is available. FD should be a file-descriptor (not a port!) open for input or output, respectively.

time->milliseconds

[procedure] (time->milliseconds TIME)

Converts a time object (as created via current-time) into an exact integer representing the number of milliseconds since process startup.

milliseconds->time

[procedure] (milliseconds->time ms)

Converts into a time object an exact integer representing the number of milliseconds since process startup.

This procedure may be useful in combination with thread-sleep! when your compilation unit is using (declare fixnum-arithmetic). In that case you won't be able to pass an inexact value to thread-sleep!, but you can do the following:

(define (thread-sleep!/ms ms)
  (thread-sleep!
   (milliseconds->time (+ ms (current-milliseconds)))))

Previous: Unit regex

Next: Unit posix